package vn.orderonline.core.commons.utils;

import java.util.Date;
import java.util.Calendar;
import java.util.concurrent.TimeUnit;

public class DateUtils extends org.apache.commons.lang.time.DateUtils {

	public static long now() {
		Calendar calendar = Calendar.getInstance(UTC_TIME_ZONE);
		return calendar.getTimeInMillis();
	}
	
	public static Date currentDate() {
		Calendar calendar = Calendar.getInstance(UTC_TIME_ZONE);
		return new Date(calendar.getTimeInMillis());
	}
	
	public static String convertLongToTime(Long time) {
		return String.format("%02d:%02d:%02d", TimeUnit.MILLISECONDS.toHours(time),
			    TimeUnit.MILLISECONDS.toMinutes(time) % TimeUnit.HOURS.toMinutes(1),
			    TimeUnit.MILLISECONDS.toSeconds(time) % TimeUnit.MINUTES.toSeconds(1));
	}
}
